/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ShootDirectionWindow.java
 *
 * Created on 2011-12-12, 19:35:15
 */

package wumpusworld;

/**
 *
 * @author Macias
 */
public class ShootDirectionWindow extends javax.swing.JFrame {

    /** Creates new form ShootDirectionWindow */
    WumpusEngine wumpusEng;

    public ShootDirectionWindow(WumpusEngine wumpusE) {

        this.wumpusEng = wumpusE;
        initComponents();
        this.addKeyListener(new MyKeyListener(this,MyKeyListener.SHOOT_WINDOW));
        this.setFocusable(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bNorth = new javax.swing.JButton();
        bSouth = new javax.swing.JButton();
        bWest = new javax.swing.JButton();
        bEast = new javax.swing.JButton();
        bCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        bNorth.setText("North");
        bNorth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bNorthActionPerformed(evt);
            }
        });

        bSouth.setText("South");
        bSouth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bSouthActionPerformed(evt);
            }
        });

        bWest.setText("West");
        bWest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bWestActionPerformed(evt);
            }
        });

        bEast.setText("East");
        bEast.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bEastActionPerformed(evt);
            }
        });

        bCancel.setText("Cancel");
        bCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bWest)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bSouth)
                    .addComponent(bNorth))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bCancel)
                    .addComponent(bEast))
                .addContainerGap(54, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bNorth)
                        .addGap(18, 18, 18)
                        .addComponent(bSouth))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(bWest)
                            .addComponent(bEast))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addComponent(bCancel)
                .addGap(24, 24, 24))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bNorthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bNorthActionPerformed
           // TODO add your handling code here:
        wumpusEng.shoot(WumpusEngine.DIRECTION_UP);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }//GEN-LAST:event_bNorthActionPerformed

    private void bSouthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSouthActionPerformed
        // TODO add your handling code here:
        wumpusEng.shoot(WumpusEngine.DIRECTION_DOWN);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }//GEN-LAST:event_bSouthActionPerformed

    private void bWestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bWestActionPerformed
        // TODO add your handling code here:
        wumpusEng.shoot(WumpusEngine.DIRECTION_LEFT);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }//GEN-LAST:event_bWestActionPerformed

    private void bEastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEastActionPerformed
        // TODO add your handling code here:
        wumpusEng.shoot(WumpusEngine.DIRECTION_RIGHT);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }//GEN-LAST:event_bEastActionPerformed

    private void bCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCancelActionPerformed
        // TODO add your handling code here:
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }//GEN-LAST:event_bCancelActionPerformed


    public void performNorthClick(){
        wumpusEng.shoot(WumpusEngine.DIRECTION_UP);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }
    public void performSouthClick(){
        wumpusEng.shoot(WumpusEngine.DIRECTION_DOWN);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }
    public void performWestClick(){
        wumpusEng.shoot(WumpusEngine.DIRECTION_LEFT);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }
    public void performEastClick(){
        wumpusEng.shoot(WumpusEngine.DIRECTION_RIGHT);
        ControlWindow.mainWindow.requestFocus();
        this.dispose();
    }
    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new ShootDirectionWindow().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bCancel;
    private javax.swing.JButton bEast;
    private javax.swing.JButton bNorth;
    private javax.swing.JButton bSouth;
    private javax.swing.JButton bWest;
    // End of variables declaration//GEN-END:variables

}
